VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmBasicARAdjustments 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   7050
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   14685
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7050
   ScaleWidth      =   14685
   ShowInTaskbar   =   0   'False
   Begin ITGControls.ITGTab SSTab1 
      Height          =   3240
      Left            =   30
      TabIndex        =   17
      Top             =   30
      Width           =   14295
      _ExtentX        =   25215
      _ExtentY        =   5715
      TabCount        =   2
      TabCaption(0)   =   "               Main               "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "ComunionFrames1"
      TabCaption(1)   =   "               List               "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "dtgList"
      TabTheme        =   2
      ActiveTabBackStartColor=   16250865
      ActiveTabBackEndColor=   16243138
      InActiveTabBackStartColor=   16243138
      InActiveTabBackEndColor=   16243138
      InActiveTabForeColor=   -2147483639
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   4210752
      TopLeftInnerBorderColor=   4210752
      BottomRightInnerBorderColor=   4210752
      DisabledTabBackColor=   -2147483633
      DisabledTabForeColor=   -2147483627
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   2925
         Left            =   -75000
         TabIndex        =   16
         Top             =   315
         Width           =   12270
         _ExtentX        =   21643
         _ExtentY        =   5159
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   6
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "Transaction No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cCode"
            Caption         =   "Client ID"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cType"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nGross"
            Caption         =   "Gross"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               Locked          =   -1  'True
               ColumnWidth     =   1725.165
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1170.142
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1484.787
            EndProperty
            BeginProperty Column03 
               Alignment       =   1
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
               Locked          =   -1  'True
               ColumnWidth     =   3179.906
            EndProperty
         EndProperty
      End
      Begin ITGControls.ComunionFrames ComunionFrames1 
         Height          =   3045
         Left            =   0
         Top             =   315
         Width           =   14295
         _ExtentX        =   25215
         _ExtentY        =   5371
         FrameColor      =   4210752
         BackColor       =   16243138
         FillColor       =   16243138
         RoundedCorner   =   0   'False
         Caption         =   "Adjustment Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ThemeColor      =   5
         ColorFrom       =   16243138
         ColorTo         =   16250865
         Begin VB.ComboBox cboType 
            Appearance      =   0  'Flat
            BackColor       =   &H00FFFFFF&
            Height          =   315
            ItemData        =   "frmBasicARAdjustments.frx":0000
            Left            =   9345
            List            =   "frmBasicARAdjustments.frx":000D
            Style           =   2  'Dropdown List
            TabIndex        =   25
            Top             =   555
            Width           =   1215
         End
         Begin VB.CommandButton cmdPickWork 
            Enabled         =   0   'False
            Height          =   285
            Left            =   3000
            Picture         =   "frmBasicARAdjustments.frx":0029
            Style           =   1  'Graphical
            TabIndex        =   5
            Top             =   1470
            Width           =   300
         End
         Begin VB.CommandButton cmdPickProject 
            Enabled         =   0   'False
            Height          =   285
            Left            =   3000
            Picture         =   "frmBasicARAdjustments.frx":0173
            Style           =   1  'Graphical
            TabIndex        =   3
            Top             =   1170
            Width           =   300
         End
         Begin VB.CommandButton cmdPickClient 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   3000
            Picture         =   "frmBasicARAdjustments.frx":02BD
            Style           =   1  'Graphical
            TabIndex        =   1
            Top             =   870
            Width           =   315
         End
         Begin VB.CommandButton cmdPickWRR 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2640
            Picture         =   "frmBasicARAdjustments.frx":0407
            Style           =   1  'Graphical
            TabIndex        =   9
            Top             =   1995
            Width           =   315
         End
         Begin VB.CommandButton cmdPickPC 
            Enabled         =   0   'False
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   5475
            Picture         =   "frmBasicARAdjustments.frx":0551
            Style           =   1  'Graphical
            TabIndex        =   10
            Top             =   1770
            Visible         =   0   'False
            Width           =   315
         End
         Begin ITGControls.ITGTextBox txtName 
            Height          =   285
            Left            =   3315
            TabIndex        =   13
            Top             =   870
            Width           =   3735
            _ExtentX        =   6482
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3675
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   165
            TabIndex        =   0
            Top             =   870
            Width           =   2820
            _ExtentX        =   4763
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Client"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1510
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtRemarks 
            Height          =   285
            Left            =   150
            TabIndex        =   11
            Top             =   2295
            Width           =   6900
            _ExtentX        =   11959
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Label           =   "Remarks"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5590
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtWRRNo 
            Height          =   285
            Left            =   150
            TabIndex        =   8
            Top             =   1995
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "WRR No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtPCDesc 
            Height          =   285
            Left            =   5790
            TabIndex        =   14
            TabStop         =   0   'False
            Top             =   1770
            Visible         =   0   'False
            Width           =   1260
            _ExtentX        =   2117
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   1200
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtPCCode 
            Height          =   285
            Left            =   3015
            TabIndex        =   7
            Top             =   1770
            Visible         =   0   'False
            Width           =   2445
            _ExtentX        =   4101
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Profit Center"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1135
            Required        =   -1  'True
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGCheckBox chkSalesReturn 
            Height          =   300
            Left            =   1455
            TabIndex        =   6
            Top             =   1725
            Width           =   1755
            _ExtentX        =   3096
            _ExtentY        =   529
            BackColor       =   16243138
            Caption         =   "Sales Return"
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            SendKeysTab     =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtGross 
            Height          =   285
            Left            =   8220
            TabIndex        =   15
            Top             =   870
            Visible         =   0   'False
            Width           =   3240
            _ExtentX        =   5503
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Gross"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   2180
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtDebit 
            Height          =   285
            Left            =   8220
            TabIndex        =   19
            Top             =   1170
            Width           =   3240
            _ExtentX        =   5503
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Total Debit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   2180
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtCredit 
            Height          =   285
            Left            =   8220
            TabIndex        =   20
            Top             =   1470
            Width           =   3240
            _ExtentX        =   5503
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   "0"
            DataType        =   1
            DecimalPlace    =   2
            Label           =   "Total Credit"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   2180
            LinkForeColor   =   0
         End
         Begin ITGControls.ITGTextBox txtProjectName 
            Height          =   285
            Left            =   3315
            TabIndex        =   23
            TabStop         =   0   'False
            Top             =   1170
            Width           =   3735
            _ExtentX        =   6482
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3675
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtProject 
            Height          =   285
            Left            =   165
            TabIndex        =   2
            Top             =   1170
            Width           =   2820
            _ExtentX        =   4763
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Project"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1510
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGTextBox txtWorkDesc 
            Height          =   285
            Left            =   3315
            TabIndex        =   24
            TabStop         =   0   'False
            Top             =   1470
            Width           =   3735
            _ExtentX        =   6482
            _ExtentY        =   503
            BackColor       =   14737632
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   3675
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtWork 
            Height          =   285
            Left            =   165
            TabIndex        =   4
            Top             =   1470
            Width           =   2820
            _ExtentX        =   4763
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Work"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1510
            Required        =   -1  'True
            LinkForeColor   =   16711680
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   5730
            TabIndex        =   26
            Tag             =   "Transaction Date"
            Top             =   555
            Width           =   1320
            _ExtentX        =   2328
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   165
            TabIndex        =   27
            Top             =   555
            Width           =   2820
            _ExtentX        =   4763
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Transaction No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1510
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtType 
            Height          =   285
            Left            =   8850
            TabIndex        =   28
            Tag             =   "cboType"
            Top             =   555
            Width           =   1710
            _ExtentX        =   2805
            _ExtentY        =   503
            LabelBackColor  =   16243138
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Mandatory       =   -1  'True
            Label           =   "Type"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1000
            TextBoxWidth    =   650
            Enabled         =   0   'False
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "Date"
            Height          =   225
            Left            =   5220
            TabIndex        =   29
            Top             =   630
            Width           =   840
         End
      End
   End
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   18
      Top             =   6765
      Width           =   14685
      _ExtentX        =   25903
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   12676
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   3000
      Left            =   30
      Top             =   3255
      Width           =   14295
      _ExtentX        =   25215
      _ExtentY        =   5292
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Details"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.ComboBox cbotype2 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Height          =   315
         ItemData        =   "frmBasicARAdjustments.frx":069B
         Left            =   450
         List            =   "frmBasicARAdjustments.frx":06A5
         Style           =   2  'Dropdown List
         TabIndex        =   22
         Top             =   1335
         Visible         =   0   'False
         Width           =   1215
      End
      Begin MSDataGridLib.DataGrid dtgAR 
         Height          =   2580
         Left            =   0
         TabIndex        =   12
         Top             =   420
         Width           =   14295
         _ExtentX        =   25215
         _ExtentY        =   4551
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Appearance      =   0
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   8
         BeginProperty Column00 
            DataField       =   "cInvNo"
            Caption         =   "Invoice No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cAcctNo"
            Caption         =   "Account No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "cTitle"
            Caption         =   "Account Title"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "nDebit"
            Caption         =   "Debit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "nCredit"
            Caption         =   "Credit"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column07 
            DataField       =   "cTypeAR"
            Caption         =   "Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               ColumnWidth     =   1170.142
            EndProperty
            BeginProperty Column01 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1200.189
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   2055.118
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   3000.189
            EndProperty
            BeginProperty Column04 
               Alignment       =   1
               ColumnWidth     =   1500.095
            EndProperty
            BeginProperty Column05 
               Alignment       =   1
               ColumnWidth     =   1500.095
            EndProperty
            BeginProperty Column06 
               ColumnWidth     =   1379.906
            EndProperty
            BeginProperty Column07 
               Button          =   -1  'True
               Locked          =   -1  'True
               Object.Visible         =   0   'False
            EndProperty
         EndProperty
      End
   End
   Begin VB.Label lblStatus 
      BackColor       =   &H00F7D9C2&
      Caption         =   "Status"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C0C0&
      Height          =   705
      Left            =   120
      TabIndex        =   21
      Top             =   6120
      Width           =   3495
   End
End
Attribute VB_Name = "frmBasicARAdjustments"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'Object variables
Private oPrint As New clsPrinting

Private AutoNum As New clsAutoNumber '---Added
Public MenuName As String '---Added

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'ADO Connection variables
Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Form mode enumeration
Enum oBasicARMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As oBasicARMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

Private sInv As String
Public nDebit, nCredit As Double

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private lSysTransDate As Boolean 'add by denz:2/17/2011 for transdate

Private Sub cboType_Click()
On Error GoTo TheSource
    txtType = Trim(cboType)
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtTranNo) = "" Then Exit Sub
    
TheSource:
    Exit Sub
End Sub

Private Sub cboType_KeyPress(KeyAscii As Integer)
    SendKeysTab KeyAscii
End Sub


Private Sub cbotype2_Click()
    rsDetail!cTypeAR = cbotype2
End Sub

Private Sub cbotype2_LostFocus()
cbotype2.Visible = False
End Sub

Private Sub chkSalesReturn_Click()
    If Mode <> AddNewEdit Then Exit Sub
    If chkSalesReturn.Value = Checked Then
        txtWRRNo.Locked = False
        cmdPickWRR.Enabled = True
    Else
        txtWRRNo.Locked = True
        cmdPickWRR.Enabled = False
    End If
End Sub

Private Sub cmdPickClient_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtCode)
    frmITGPicker.zType = QCustomer
    'added condition
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    txtName = frmITGPicker.zName
    If Trim(txtName) <> "" Then SendKeys "{Tab}"
End Sub

'Private Sub cmdPickPC_Click()
'    If lPickListActive Then Exit Sub
'    frmITGPickList.mType = ProfitCenter
'    'added condition
'    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
'
'    frmITGPickList.Show vbModal
'    rsHeader!cPCCode = frmITGPickList.mCode
'    txtPCCode = frmITGPickList.mCode
'    If Trim(txtPCDesc) <> "" Then SendKeys "{Tab}"
'End Sub

Private Sub cmdPickWRR_Click()
    If Trim(txtCode) = "" Then
        MsgBox "Please select customer code.", vbExclamation, msgTtl
        txtCode.SetFocus
        Exit Sub
    End If
    If lPickListActive Then Exit Sub
    RepName = Trim(txtCode)
    frmITGPickList.mType = ARDRCR_WRR
    frmITGPickList.Show vbModal
    txtWRRNo = frmITGPickList.mCode
    If Trim(txtWRRNo) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgAR_AfterColUpdate(ByVal ColIndex As Integer)
            
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 1
            If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'") <> "" Then
                dtgAR.Columns(2).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'")
                dtgAR.Columns(3).Value = rsDetail!cDesc
            End If
        Case 4
            If CDbl(dtgAR.Columns(4).Value) > 0 Then dtgAR.Columns(5).Value = 0
            TotalAdjustmentAmount
        Case 5
            If CDbl(dtgAR.Columns(5).Value) > 0 Then dtgAR.Columns(4).Value = 0
            TotalAdjustmentAmount
    End Select
    
End Sub

Private Sub dtgAR_ButtonClick(ByVal ColIndex As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            RepName = Trim(txtCode)
            If rsHeader!lSalesReturn = True Then
                RepName = Trim(txtCode)
                cString = Trim(txtWRRNo)
                frmARCollectionList.mSIPick = ToDebitCreditSR
            Else
                frmARCollectionList.mSIPick = ToDebitCredit
            End If
            frmARCollectionList.Show vbModal
            If Trim(frmARCollectionList.mcInvNo) = "" Then Exit Sub
            dtgAR.Columns(0).Value = Trim(frmARCollectionList.mcInvNo) & ""
            dtgAR.Col = 1
            If sInv = "" Then
                dtgAR.Columns(1).Value = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_AR'")
                dtgAR.Columns(2).Value = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'")
            Else
                dtgAR.Columns(1).Value = rsDetail!cAcctNo
            End If
        Case 1
            If lPickListActive Then Exit Sub
            sFilterString = Trim(dtgAR.Columns(1).Text)
            frmITGPicker.zType = QAccounts
            'added condition
            frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
            
            frmITGPicker.Show vbModal
            If Trim(frmITGPicker.zCode) = "" Then Exit Sub
            If Trim(dtgAR.Columns(0).Text) = "" Then dtgAR.Columns(0).Value = "---"
            dtgAR.Columns(1).Value = frmITGPicker.zCode & ""
            dtgAR.Columns(2).Value = frmITGPicker.zName & ""
            dtgAR.Col = 3
            dtgAR.Columns(3).Value = rsDetail!cDesc
        Case 7
                Call MoveCombo(cbotype2, dtgAR, dtgAR.Columns(7))
                ComboLoadValue cbotype2, Trim(dtgAR.Columns(7).Text)
    End Select

End Sub

'Set the datagrid as active control
Private Sub dtgAR_Click()
    If Mode = AddNewEdit Then dtgName = dtgAR.Name
End Sub

Private Sub dtgAR_Error(ByVal DataError As Integer, Response As Integer)
    If Mode <> AddNewEdit Then
        Response = 0
        Exit Sub
    End If
    If DataError = 7007 Then
        MsgBox "Type mismatch", vbExclamation, msgTtl
    ElseIf DataError = 13 Then
        MsgBox "Type mismatch", vbExclamation, msgTtl
    End If
    Response = 0
End Sub

Private Sub dtgAR_GotFocus()
    dtgName = dtgAR.Name
End Sub

Private Sub dtgAR_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgAR_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub

    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgAR.Col
            Case 0
                sSQL = "SELECT A.cInvNo FROM SALES A " & _
                        "INNER JOIN V_SalesBalanceInquiry B ON A.cInvNo = B.cInvNo " & _
                        "WHERE A.cInvNo = '" & Trim(dtgAR.Columns(0).Value) & "' " & _
                        "AND A.cCompanyID = '" & COID & "' " & _
                        "AND ((B.nSales - B.nPaid - B.nReturns - B.nCredit + B.nDebit) <> 0)"
                Set rs = New Recordset
                rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
                If rs.RecordCount = 0 Then
                    dtgAR.Col = 0
                    dtgAR_ButtonClick 0
                Else
                    SendKeys "{Tab}"
                End If
                Set rs = Nothing
            Case 1
                If GetValueFrTable("cAcctNo", "ACCOUNT", "cAcctNo = '" & Trim(dtgAR.Columns(1).Text) & "'") = "" Then
                    dtgAR_ButtonClick (1)
                    Exit Sub
                End If
                SendKeys "{Tab}"
                SendKeys "{Tab}"
            Case 6
                TBNewLine
                dtgAR.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(Chr(KeyAscii))
    End If

End Sub

'Right click menu popup
Private Sub dtgAR_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgAR.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub


Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'BAR04'")
    
    'Load OrderType Values
    sSQL = "(SELECT module_id FROM erp_sec_modules WHERE link = '" & Me.Name & "')"
    Call LoadComboValues(cboType, "RefType", "ComboValueSetUp", "Where RefModule = " & sSQL & " AND Visible = 1 and cCompanyID = '" & Trim(COID) & "'")

    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    FormLocking True
    FormSearch True
    SearchObj True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , True, True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtTranNo.Locked = False
    
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing
    Set oPrint = Nothing

    Set frmBasicARAdjustments = Nothing

    lCloseWindow = True
    
    ''oForm(Me.Tag).Mode = 1
    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        OpenNewConnection connHeader
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "AR_T", connDetail, "WHERE 1 = 0"
        OpenRecordsetWithCN rsHeader, "*", "AR", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date
    rsHeader!cType = "Credit"
'    rsHeader!cPCCode = sDivision
    rsHeader!lSalesReturn = False
    
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    txtWRRNo.Locked = True
    cmdPickWRR.Enabled = False
    SSTab1.ActiveTab = 0
    txtTranNo.SetFocus
    txtTranNo.Locked = True
    'system generated numbe
'    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_ARCM' ")
'    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_ARCM", "AR", "cTranNo")
    
    MenuName = "AUTO_NUMBER_ARCM"
    
    lSystemGenerated = GetValueFrTable("lAutoNo", "system_autonumber", "cCode = '" & MenuName & "' ")
    If lSystemGenerated Then rsHeader!cTranNo = AutoNum.Generate_CtrlNo2(MenuName, Format(Now, "mm/dd/yyyy"))
    
    strNo = rsHeader!cTranNo
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    If rsHeader.Status = adRecNew Then TBUndoCurrent
    
    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM
    
    Set FrmName = Me
    FormLocking True
    
    If rsHeader.RecordCount <> 0 Then
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, , True, True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""
    
    SetDataSource
    SetDataField

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
   
    If rsHeader.RecordCount = 0 Then RSZero
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    lSaving = True

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True
    
    If Not MandatoryOK Then Exit Sub
    
    TotalGrossAmount
    
    'System generated number
    If rsHeader.Status = adRecNew Then
        If lSystemGenerated Then
            If Trim(cboType) = "Credit" Then
                'If ChkCtrlNo(rsHeader, "AUTO_NUMBER_ARCM", "AR", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                If AutoNum.Check_CtrlNo2(rsHeader, "AR", "cTranNo", rsHeader!cTranNo, "AUTO_NUMBER_ARCM", rsHeader!dDate) <> rsHeader!cTranNo Then
                    GetChild
                    
                    rsHeader!cTranNo = strNo
                    
                    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                    Do Until rsDetail.EOF
                        rsDetail!cTranNo = strNo
                        rsDetail.MoveNext
                    Loop
                    
                    GetChild
                End If
            ElseIf Trim(cboType) = "Debit" Then
                'If ChkCtrlNo(rsHeader, "AUTO_NUMBER_ARDM", "AR", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                If AutoNum.Check_CtrlNo2(rsHeader, "AR", "cTranNo", rsHeader!cTranNo, "AUTO_NUMBER_ARDM", rsHeader!dDate) <> rsHeader!cTranNo Then
                    GetChild
                    
                    rsHeader!cTranNo = strNo
                    
                    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                    Do Until rsDetail.EOF
                        rsDetail!cTranNo = strNo
                        rsDetail.MoveNext
                    Loop
                    
                    GetChild
                End If
            End If
        End If
    End If
    
    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, False, , , lACPost, lACCancel, , , True, True, True, True, True
    Mode = Normal
    
    'Audit trail
    UpdateLogFile "AR Adjustments", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")

    'update system generated number
    If lBoolean Then
        If Trim(cboType) = "Credit" Then
            If lSystemGenerated And strNo = rsHeader!cTranNo Then
                UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_ARCM"
                AutoNum.Update_CtrlNo2 strNo, "AUTO_NUMBER_ARCM", Format(Now, "mm/dd/yyyy")
            End If
        ElseIf Trim(cboType) = "Debit" Then
            If lSystemGenerated And strNo = rsHeader!cTranNo Then
                UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_ARDM"
                AutoNum.Update_CtrlNo2 strNo, "AUTO_NUMBER_ARDM", Format(Now, "mm/dd/yyyy")
            End If
        End If
    End If
    
    If lBoolean = False Then ' Edit
        cn.Execute ("UPDATE AR SET  dUpdated = GETDATE ()  WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    Else ' Insert
        cn.Execute ("UPDATE AR SET  dUpdated = GETDATE ()  WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    End If
    
    MsgBox "Record/s successfully saved.", vbInformation, msgTtl
    sbRS.Panels(2) = ""
    
        Dim sum1 As Double
        Dim sum2 As Double
        sum1 = 0
        sum2 = 0
        While Not rsDetail.EOF
        sum1 = sum1 + rsDetail!nDebit
        sum2 = sum2 + rsDetail!nCredit
        rsDetail.MoveNext
        Wend
        txtDebit = sum1
        txtCredit = sum2

ErrHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, msgTtl
        vBookMark = rsHeader.Bookmark
        UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , lACPost, lACCancel, , , True, True, True, True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, msgTtl
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    lSaving = False
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Edit is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already approved. Edit is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
    txtGross.Locked = True
    txtTranNo.Locked = True
    If rsHeader!lSalesReturn = True Then
        txtWRRNo.Locked = False
        cmdPickWRR.Enabled = True
    Else
        txtWRRNo.Locked = True
        cmdPickWRR.Enabled = False
    End If
    SSTab1.ActiveTab = 0
    dtbDate.SetFocus
    cboType.Enabled = False
    vBM = rsHeader.Bookmark
    
   
    MenuName = "AUTO_NUMBER_ARCM"
    lSysTransDate = GetValueFrTable("lTransDate", "system_autonumber", "cCode = '" & MenuName & "' ") 'add by denz:2/17/2011
    If lSysTransDate Then
        dtbDate.Enabled = True
    Else: dtbDate.Enabled = False
    End If
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtTranNo)
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Deletion is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already approved. Deletion is not allowed.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, msgTtl) = vbNo Then Exit Sub

    'Update GL Activity
    UpdateGLA "Delete", "AR", Trim(txtTranNo)
    
    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    'Audit trail
    UpdateLogFile "AR Adjustments", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    TBPrevRec

    Mode = Normal
    
    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        cn.Execute "DELETE AR_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE AR WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If

End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow App.Path & "\Transmit.avi", "Loading data . . ."
            
    OpenNewConnection connHeader
    OpenNewConnection connDetail
                
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If
    
    OpenRecordsetWithCN rsHeader, "*", "AR", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
           
    OpenRecordsetWithCN rsDetail, "*", "AR_T", connDetail, IIf(sTemp = "", "", " WHERE cTranNo IN (SELECT cTranNo FROM AR WHERE " & sTemp & ")")
    
    Set FrmName = Me
    FormLocking True

    If rsHeader.RecordCount = 0 Then
        FormWaitHide
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    
        Dim sum1 As Double
        Dim sum2 As Double
        sum1 = 0
        sum2 = 0
        While Not rsDetail.EOF
        sum1 = sum1 + rsDetail!nDebit
        sum2 = sum2 + rsDetail!nCredit
        rsDetail.MoveNext
        Wend
        txtDebit = sum1
        txtCredit = sum2
    
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, False, , , lACPost, lACCancel, , , True, True, True, True, True

    FormWaitHide
Else
    RSZero
    FormSearch True
    SearchObj True
    Mode = Find
End If
End Sub

Public Sub TBAccountAffected()
    RepName = "AR"
    frmAccountAffected.mModuleType = KAR
    frmAccountAffected.mRefPK = txtTranNo.Text
    frmAccountAffected.Show vbModal
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgAR.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveFirst rsHeader
    
End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MovePrevious rsHeader
    
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveNext rsHeader
        
End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    MoveLast rsHeader
End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()

    
    If rsHeader!cTranNo = "" Then Exit Sub
    If Trim(txtCode) = "" Then
        MsgBox "Please select client.", vbExclamation, msgTtl
        txtCode.SetFocus
        Exit Sub
    End If
    
    If dtgName = "dtgAR" Then
        sInv = Empty
        If rsDetail.RecordCount > 0 Then
            'If Trim(dtgAR.Columns(1).Text) = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_AR'") Then sInv = Trim(dtgAR.Columns(0).Text)
            
        End If
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cTranNo = Trim(rsHeader!cTranNo)
        dtgAR.Col = 3
        GetChild
        If rsDetail.RecordCount <> 0 Then
            rsDetail.MoveLast
            cboType.Enabled = False
        End If
        dtgAR.Col = 0
        dtgAR.Columns(0).Value = sInv
        dtgAR.SetFocus
    End If
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = dtgAR.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgAR.Bookmark
        GetChild
        dtgAR.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If
    GetChild

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
On Error GoTo TheSource
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled. Approval is not allowed", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If rsHeader!lApproved = True Then
        MsgBox "Transaction was already approved.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to approve this record?", vbQuestion + vbYesNo, msgTtl) = vbNo Then Exit Sub

    'Audit trail
    UpdateLogFile "AR Adjustments", Trim(txtTranNo), "Approved"

    'Update GL Activity
    UpdateGLA "Update", "AR", Trim(txtTranNo)
    
    cn.Execute ("UPDATE AR SET lApproved = 1, dUpdated = GETDATE ()  WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "APPROVED"
    Mode = Normal
    
    rsHeader!lApproved = True
    rsHeader.UpdateBatch adAffectAll

TheSource:
    If err.Number = -2147217885 Then
        Resume Next
    End If
End Sub

'Cancel current record
Public Sub TBCancelRecord()
On Error GoTo ErrorHandler
    
    If rsHeader.RecordCount = 0 Then Exit Sub

    If rsHeader!lCancelled = True Then
        MsgBox "Transaction was already cancelled.", vbExclamation, msgTtl
        Exit Sub
    ElseIf rsHeader!lApproved = True Then
        MsgBox "Cannot cancel approved transaction.", vbExclamation, msgTtl
        Exit Sub
    End If
    
    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, msgTtl) = vbNo Then Exit Sub
    

    'Audit trail
    UpdateLogFile "AR Adjustments", Trim(txtTranNo), "Cancelled"

    cn.Execute ("UPDATE AR SET lCancelled = 1, dUpdated = GETDATE () WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
    
    sbRS.Panels(5) = "CANCELLED"
    Mode = Normal
    
    rsHeader!lCancelled = True
    rsHeader.UpdateBatch adAffectAll

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Print
Public Sub TBPrintRecord()
    RepName = "Basic_ARCMDM_Adjustment_Trans"
    cModule = "Basic_ARCMDM_Adjustment"
    oPrint.PrintReceipt Trim(txtTranNo)
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgAR.DataSource = rsDetail
    
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtType.DataField = !cType
        txtCode.DataField = !cCode
        txtRemarks.DataField = !cRemarks
        chkSalesReturn.DataField = !lSalesReturn
        txtWRRNo.DataField = !cWRRNo
        txtGross.DataField = !nGross
        txtWork.DataField = !cWorkID
'        txtPCCode.DataField = !cPCCode
    End With
End Sub


Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If
        
        
       If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If
        
        GetChild
    
        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
            lblStatus = "CANCELLED"
        ElseIf rsHeader!lApproved = True Then
            sbRS.Panels(5) = "APPROVED"
            lblStatus = "APPROVED"
        Else
            sbRS.Panels(5) = ""
            lblStatus = ""
        End If
        
        Dim sum1 As Double
        Dim sum2 As Double
        sum1 = 0
        sum2 = 0
        While Not rsDetail.EOF
        sum1 = sum1 + rsDetail!nDebit
        sum2 = sum2 + rsDetail!nCredit
        rsDetail.MoveNext
        Wend
        txtDebit = sum1
        txtCredit = sum2
        
        
    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgAR.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCode_Change()
    txtName = ""
    txtName = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'")
End Sub

Private Sub txtCode_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtName) = "" And Trim(txtCode) <> "" Then cmdPickClient_Click
End Sub

'Private Sub txtPCCode_Change()
'    txtPCDesc = ""
'    txtPCDesc = GetValueFrTable("cDescription", "PROFITCENTER", "cPCCode = '" & Trim(txtPCCode) & "'")
'End Sub

'Private Sub txtPCCode_LostFocus()
'    If Mode <> AddNewEdit Then Exit Sub
'    If Trim(txtPCDesc) = "" And Trim(txtPCCode) <> "" Then cmdPickPC_Click
'End Sub

Private Sub txtRemarks_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then TBNewLine
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, msgTtl
            If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "AR", Trim(rsHeader!cTranNo)) Then
                MsgBox "Transaction No. already exist.", vbInformation, msgTtl
                If FrmName.Name <> Me.Name Then PreviousTab frmComUnionMenuTab
                txtTranNo.SetFocus
            End If
        End If
    End If
End Sub

Private Sub txtType_Change()
    If Trim(txtType) <> "" Or txtType <> vbNullString Then
        cboType = Trim(txtType)
    Else
        cboType.ListIndex = -1
    End If
    
    If Mode = AddNewEdit Then
        If Trim(cboType) = "Credit" Then
            MenuName = "AUTO_NUMBER_ARCM"
            lSystemGenerated = GetValueFrTable("lAutoNo", "system_autonumber", "cCode = '" & MenuName & "'")
            If lSystemGenerated Then rsHeader!cTranNo = AutoNum.Generate_CtrlNo2(MenuName, Format(Now, "mm/dd/yyyy"))
        ElseIf Trim(cboType) = "Debit" Then
            MenuName = "AUTO_NUMBER_ARDM"
            lSystemGenerated = GetValueFrTable("lAutoNo", "system_autonumber", "cCode = '" & MenuName & "'")
            If lSystemGenerated Then rsHeader!cTranNo = AutoNum.Generate_CtrlNo2(MenuName, Format(Now, "mm/dd/yyyy"))
        Else
            lSystemGenerated = False
            rsHeader!cTranNo = ""
            txtTranNo.SetFocus
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Number' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        txtTranNo.SetFocus
        Exit Function
    End If
    
    TotalAdjustmentAmount
    
    If nDebit <> nCredit Then
        MsgBox "Unbalanced transaction details.", vbCritical, msgTtl
        MandatoryOK = False
        Exit Function
    End If
    
    
    
    
    If rsHeader.Status = adRecNew And lSystemGenerated = False Then
        If IDExisting(rsHeader, "cTranNo", "AR", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "Transaction No. already exist.", vbInformation, msgTtl
            txtTranNo.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        dtbDate.SetFocus
        Exit Function
    ElseIf Trim(txtType) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Type' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        cboType.SetFocus
        Exit Function
    ElseIf Trim(txtCode) = "" Then
        MandatoryOK = False
        MsgBox "Field 'Client' is mandatory. Null value is not allowed.", vbInformation, msgTtl
        txtCode.SetFocus
        Exit Function
'    ElseIf Trim(txtPCCode) = "" Then
'        MandatoryOK = False
'        MsgBox "Field 'Profit Center' is mandatory. Null value is not allowed.", vbInformation, msgttl
'        txtPCCode.SetFocus
'        Exit Function
    ElseIf chkSalesReturn.Value = Checked Then
        If Trim(txtWRRNo) = "" Then
            MandatoryOK = False
            MsgBox "Field 'WRR No.' is mandatory. Null value is not allowed.", vbInformation, msgTtl
            txtWRRNo.SetFocus
            Exit Function
        End If
    End If
    
    GetChild
    
    'Transaction without details
    If rsDetail.RecordCount < 1 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, msgTtl
        dtgAR.SetFocus
        Exit Function
    End If
 
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cInvNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cInvNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, msgTtl
        MandatoryOK = False
        Exit Function
    End If

    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.EOF
            rsDetail!nIdentity = rsDetail.AbsolutePosition
            rsDetail.MoveNext
        Loop
    End If
    
End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""
    
    Set dtgAR.DataSource = Nothing
    dtgAR.Refresh
    
    Set FrmName = Me
    UnbindControls
    TextClearing
    FormLocking True
    
    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    
    txtTranNo.Locked = False
    txtTranNo.SetFocus
    
    Mode = Find
    
End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cboType.Enabled = lEnable
    cmdPickClient.Enabled = lEnable
    cmdPickWRR.Enabled = lEnable
    cmdPickProject.Enabled = lEnable
    cmdPickWork.Enabled = lEnable
End Sub

'compute total adjustment
Sub TotalAdjustmentAmount()
On Error Resume Next
    
    If Mode <> AddNewEdit Then Exit Sub
    
    nDebit = 0
    nCredit = 0
    
    Set rs = New Recordset
    Set rs = rsDetail.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    Do Until rs.EOF
            nDebit = nDebit + IIf(IsNull(rs!nDebit), 0, rs!nDebit)
            nCredit = nCredit + IIf(IsNull(rs!nCredit), 0, rs!nCredit)
        rs.MoveNext
    Loop
    Set rs = Nothing
    If UCase(Trim(rsHeader!cType)) = "DEBIT" Then
        rsHeader!nGross = nDebit
    ElseIf UCase(Trim(rsHeader!cType)) = "CREDIT" Then
        rsHeader!nGross = nCredit
    End If
End Sub

Sub TotalGrossAmount()
Dim acct As String
On Error Resume Next
    If Mode <> AddNewEdit Then Exit Sub
    nDebit = 0
    nCredit = 0
    Set rs = New Recordset
    Set rs = rsDetail.Clone
    rs.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
    acct = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_AR'")
    Do Until rs.EOF
        If rs!cAcctNo = acct Then
            nDebit = nDebit + IIf(IsNull(rs!nDebit), 0, rs!nDebit)
            nCredit = nCredit + IIf(IsNull(rs!nCredit), 0, rs!nCredit)
        End If
        rs.MoveNext
    Loop
    Set rs = Nothing
    If UCase(Trim(rsHeader!cType)) = "DEBIT" Then
        rsHeader!nGross = nDebit
    ElseIf UCase(Trim(rsHeader!cType)) = "CREDIT" Then
        rsHeader!nGross = nCredit
    End If
End Sub

Private Sub txtWRRNo_Change()
    If Mode <> AddNewEdit Then Exit Sub
    If cmdPickWRR.Enabled = False Then Exit Sub
    If GetValueFrTable("cWRRNo", "WRR", "cWRRNo = '" & Trim(txtWRRNo) & "' AND cCode = '" & Trim(txtCode) & "' AND cType = 'Sales Return'") = "" Then Exit Sub
    If Trim(txtWRRNo) <> "" Then
        Dim sAR, sARTitle, sVat, sReturn, sReturnTitle, sVATTitle As String
        Dim nVatRate As Double
        sAR = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_AR'")
        sReturn = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_RETURN'")
        sVat = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_DEFVAT'")
        sARTitle = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(sAR) & "'")
        sReturnTitle = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(sReturn) & "'")
        sVATTitle = GetValueFrTable("cTitle", "ACCOUNT", "cAcctNo = '" & Trim(sVat) & "'")
        nVatRate = GetValueFrTable("cValue", "SYSTEM_OPTION", "cCode = 'DEF_VAT_RATE'")
        
        sSQL = "SELECT cRefNo, SUM(nAmount) AS nAmount FROM WRR_T " & _
                "WHERE cCompanyID = '" & COID & "' AND cWRRNo = '" & Trim(txtWRRNo) & "' " & _
                "GROUP BY cRefNo"
        Set rs = New Recordset
        rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
        
        Do While Not rs.EOF
            With rsDetail
                    Dim cRemarks As String
                    Dim n, m As Double
                    
                    n = rs!nAmount
                    m = n * (1 - (1 / (1 + nVatRate / 100)))
                    cRemarks = IIf(IsNull(rsHeader!cRemarks), "", rsHeader!cRemarks)
                .AddNew
                !cCompanyID = COID
                !cTranNo = Trim(rsHeader!cTranNo)
                !cInvNo = rs!cRefNo
                !cAcctNo = sAR
                !cTitle = sARTitle
                !nDebit = 0
                !nCredit = rs!nAmount
                !cDesc = cRemarks
            
                .AddNew
                !cCompanyID = COID
                !cTranNo = Trim(rsHeader!cTranNo)
                !cInvNo = rs!cRefNo
                !cAcctNo = sReturn
                !cTitle = sReturnTitle
                !nDebit = rs!nAmount - Round(m, 2)
                !nCredit = 0
                !cDesc = cRemarks
                
                .AddNew
                !cCompanyID = COID
                !cTranNo = Trim(rsHeader!cTranNo)
                !cInvNo = rs!cRefNo
                !cAcctNo = sVat
                !cTitle = sVATTitle
                !nDebit = Round(m, 2)
                !nCredit = 0
                !cDesc = cRemarks
                
            End With
            rs.MoveNext
        Loop
                                
        Set rs = Nothing
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        TotalAdjustmentAmount
    End If

End Sub

Private Sub txtWRRNo_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If cmdPickWRR.Enabled = False Then Exit Sub
    If GetValueFrTable("cWRRNo", "WRR", "cWRRNo = '" & Trim(txtWRRNo) & "' AND cCode = '" & Trim(txtCode) & "' AND cType = 'Sales Return'") = "" Then cmdPickWRR_Click
End Sub


Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranno LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If
    
    If Trim$(txtType.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cType LIKE '" & Trim$(txtType.Text) & "%'"
    End If
    
    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If
    
    If Trim$(txtWRRNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cWRRNo LIKE '" & Trim$(txtWRRNo.Text) & "%'"
    End If
    
    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

'Change Transaction Number
Sub ChangeTranNo(strTranNo As String)
    GetChild
    
    rsHeader!cTranNo = strTranNo
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        rsDetail!cTranNo = strTranNo
        rsDetail.MoveNext
    Loop
    
    GetChild
End Sub


Public Sub ShowForm(sTranNo As String)
    If Mode = Find Then

        OpenNewConnection connHeader
        OpenNewConnection connDetail

        Set rsHeader = Nothing
        Set rsDetail = Nothing
        Set rsHeader = New ADODB.Recordset
        Set rsDetail = New ADODB.Recordset


        OpenRecordsetWithCN rsDetail, "*", "AR_T", connDetail, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
        OpenRecordsetWithCN rsHeader, "*", "AR", connHeader, "WHERE cTranNo = '" & Trim(sTranNo) & "'"

        Set FrmName = Me
        FormLocking True

        If rsHeader.RecordCount = 0 Then
            FormWaitHide
            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
            RSZero
            FormSearch True
            SearchObj True
            Mode = Find
            Exit Sub
        End If
            SetDataSource
            SetDataField
            txtTranNo.BackColor = &HE0FFFF
            Mode = Normal
            BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , lACCancel, , , True, True, lACPrint, True, True

            'BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True

    End If
End Sub

Private Sub txtProject_Change()
    txtProjectName = ""
    txtProjectName = GetValueFrTable("cProjectName", "Project_Maintenance", "cProjectNo = '" & Trim(txtProject) & "'")
End Sub


Private Sub txtProject_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtProject) = "" And Trim(txtProject) <> "" Then cmdPickProject_Click
End Sub

Private Sub cmdPickProject_Click()
    If lPickListActive Then Exit Sub
    sFilterString = Trim(txtProject)
    frmITGPicker.zType = QProject
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "'"
    
    frmITGPicker.Show vbModal
    txtProject = frmITGPicker.zCode
    txtProjectName = frmITGPicker.zName
    If Trim(txtProjectName) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub txtWork_Change()
    txtWorkDesc = ""
    If txtProject.Text = "" Then: txtProject.SetFocus: Exit Sub
    txtWorkDesc = GetValueFrTable("description", "Work_Maintenance_File", "workno = '" & Trim(txtWork) & "' ") 'and cProjectNo =  '" & Trim(txtProject) & "'")
End Sub


Private Sub cmdPickWork_Click()
    If lPickListActive Then Exit Sub
'    sFilterString = Trim(txtWork)
    frmITGPicker.zType = QWork
    frmITGPicker.Condition = "where cCompanyID = '" & COID & "' " 'and cProjectNo = '" & Trim(txtProject) & "'"
    
    frmITGPicker.Show vbModal
    txtWork = frmITGPicker.zCode
    txtWorkDesc = frmITGPicker.zName
    If Trim(txtWorkDesc) <> "" Then SendKeys "{Tab}"
End Sub


Private Sub txtWork_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If Trim(txtWork) = "" And Trim(txtWork) <> "" Then cmdPickWork_Click
End Sub
